'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')

module.exports = {
  dev: {

    // Paths
    assetsSubDirectory: 'static', //通过服务器访问static的文件,url输入aaa其实是访问static的, static永远不变, 只是输入的要是http://loacalhost:8080/aaa/mock/indexx.js才能访问到static下的mock下的index.json, 但是如果是aaa的话, 那么下面的^api: 也要是/aaa/mock这样不好
    assetsPublicPath: '/',  //如果填/b那么根路径从/变成/b
    proxyTable: {
      '/api': {
        target: 'http://localhost:8080',
        pathRewrite: {
          '^/api': '/static/mock'
        }
      },
      '/07Vue/travel03/api': {
        target: 'http://localhost:8080',
        pathRewrite: {
          '^/07Vue/travel03/api': '/static/mock'
        }
      },
      './mock': {
        target: 'http://localhost:8080',
        pathRewrite: {
          '^./mock': '/static/mock'
        }
      },
      '/mock': {
        target: 'http://localhost:8080',
        pathRewrite: {
          '^/mock': '/static/mock'
        }
      },


    },

    // Various Dev Server settings
    host: 'localhost', // can be overwritten by process.env.HOST
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    
    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'cheap-module-eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },

  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    // 原来是/ 我改成了./试试,  还是./好, /变成根了... 如果是一个网站放一个dist文件的话, 用/是没有问题的
    assetsPublicPath: './', // 用"/"是某个网站的某个端口的根目录,如果是企业网站的话这么做好, 像我这种个人学习项目还是用相对目录好, 毕竟一个网站放多少个"网页项目"

    /**
     * Source Maps
     */

    productionSourceMap: true,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }
}
